package com.qding.park.common.utils.csv;

import java.util.TreeMap;

import com.univocity.parsers.common.Format;
import com.univocity.parsers.csv.CsvFormat;

public class MyCsvFormat extends CsvFormat{
    
    private  String  lineSeparatorString;
    
    private char[] lineSeparator;
    
//    protected MyCsvFormat() {
//        this.lineSeparator = systemLineSeparator.clone();
//        this.lineSeparatorString = systemLineSeparatorString;
//    }
    
    public void setLineSeparator(char[] lineSeparator) {
        if (lineSeparator == null || lineSeparator.length == 0) {
            throw new IllegalArgumentException("Invalid line separator. Expected 1 to 5 characters");
        }
        if (lineSeparator.length > 5) {
            throw new IllegalArgumentException("Invalid line separator. Up to 5 characters are expected. Got " + lineSeparator.length + " characters.");
        }
        this.lineSeparator = lineSeparator;
        this.lineSeparatorString = new String(lineSeparator);
    }
    
    public String getLineSeparatorString() {
        return lineSeparatorString;
    }

    public char[] getLineSeparator() {
        return lineSeparator.clone();
    }

}
